// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.gameScene = ck.getGameScene()
    },

    onCollisionEnter: function (playerCollider, self) {
        if (this.gameScene.data.state === ck.GameState.Prepare)
            return

        if (this.gameScene.data.state === ck.GameState.TouchDoor)
            return

        if (this.gameScene.data.state === ck.GameState.Finished)
            return

        if (this.gameScene.data.state === ck.GameState.Dead)
            return
        
        playerCollider.node.getComponent('Player').setDead(true)
    },
});
